﻿using System;
using System.Collections.Generic;
using System.IO;

namespace ByteShower
{
    partial class Program
    {
        static string path;
        static string input = "";
        static string command = "";
        static List<string> userArgs = new List<string>();
        static void Main(string[] args)
        {
            if(args.Length != 0)
                path = args[0].StartsWith(@".\") ? AppContext.BaseDirectory + args[0].Substring(2) : args[0];
            while(true)
            {
                Data(">>>  ");
                input = "";
                userArgs.Clear();
                input = Console.ReadLine().ToLower();
                userArgs.AddRange(input.Split(' '));
                command = userArgs[0];
                userArgs.RemoveAt(0);
                for (int i = 0; i < userArgs.Count; i++)
                    userArgs[i] = TransString(userArgs[i]);
                if(command == "exit")
                    break;
                switch (command)
                {
                    case "createfile":
                        CreateFile();
                        break;
                    case "setpath":
                        path = userArgs[0].StartsWith(@".\") ? AppContext.BaseDirectory + userArgs[0].Substring(2) : userArgs[0];
                        Info("Current file path:\n" + path + '\n');
                        break;
                    case "printfile":
                        PrintFile();
                        break;
                    case "renamefile":
                        if(userArgs.Count >= 2)
                            RenameFile(userArgs[0], userArgs[1]);
                        else
                            RenameFile(userArgs[0]);
                        break;
                    default:
                        Error("No such command!\n");
                        break;
                }
                Console.ForegroundColor= ConsoleColor.Gray;
            }
        }
    }
}
